package test.zdx.杂七杂八;

import java.util.Arrays;


        /*
暴力搜索，动态更新
题目强调只包含两个小写字母，就是要求26个字母开成数组存储，
每次两个匹配到的数组扫描之后，用存储的数组进行比较，如果两个计数数组都存在大于等于一的元素，这两个没戏了
其次可以看一下这些字母，排序之后！！排序个屁，已验证，字符串数组无法排序

*/
//万物皆自暴力而来优化。冲冲冲！

        public class Solution111
        {

            public static int maxProduct(String[] words) {
                int lenArr = words.length;
                int lenMax = Integer.MIN_VALUE;
                int curlen = 0;
                for (int i = 0; i < lenArr - 1; i++) {
                    char arri[] = words[i].toCharArray();
                    int[] cnti = new int[26];
                    for (char m : arri) {
                        cnti[m - 'a']++;
                    }

                    for (int j = i + 1; j < lenArr; j++) {

                        char arrj[] = words[j].toCharArray();
                        int[] cntj = new int[26];
                        for (char n : arrj) {
                            cntj[n - 'a']++;
                        }
//                        System.out.println("此处没问题！");
//                        System.out.println(cnti);
//                        System.out.println(cntj);
                        int flag = 0;
                        for (int p = 0; p < 26; p++) {
//                            System.out.println("没问题");
                            if (cnti[p] >= 1 && cntj[p] >= 1)
                                flag=1;
                        }

//                        System.out.println(leni);
//                        System.out.println(lenj);
                        // curlen= words[i].length() * words[j].length();
                        if(flag == 0)
                        {
                            int leni = words[i].length();
                            int lenj = words[j].length();
                            curlen = leni * lenj;
                        }
                        lenMax = lenMax > curlen ? lenMax : curlen;
                    }
                }
                return lenMax;

            }

            public static void main(String[] args) {
//                String []s ={"abcw","baz","foo","bar","xtfn","abcdef"};
//                String []s ={"abcw","foo"};
                String []s ={"a","aa","aaa","aaaa"};
//                String []s ={"a","ab","abc","d","cd","bcd","abcd"};
                System.out.println(maxProduct(s));
            }
        }

